package com.bml.architect.gateway.config;

import com.alibaba.cloud.sentinel.datasource.converter.JsonConverter;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Flux;

/**
 * @author: baiml
 * @Title: GwConfig
 * @ProjectName: 中台技术平台
 * @Depart 中台研发部
 * @Description:
 * @date: 2021/5/18 17:41
 */
@Configuration
public class GwConfig {

    private ObjectMapper objectMapper = new ObjectMapper();

    public  GwConfig(){
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
                false);
    }

    /**
     * 添加网关的转换器
     * @return
     */
    @Bean("sentinel-json-gw-flow-converter")
    public JsonConverter jsonGwFlowConverter() {
        return new JsonConverter(objectMapper, GatewayFlowRule.class);
    }
}
